﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class add_table_StdTableRestrRule : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MainStdTableRestrRule",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdTableDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    StdTableColumnDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    TableRestrRuleProvider = table.Column<int>(type: "integer", nullable: false),
                    RestrRuleValue = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MainStdTableRestrRule", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MainStdTableRestrRule_MainStdTableColumnDict_StdTableColumn~",
                        column: x => x.StdTableColumnDictId,
                        principalTable: "MainStdTableColumnDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_MainStdTableRestrRule_MainStdTableDict_StdTableDictId",
                        column: x => x.StdTableDictId,
                        principalTable: "MainStdTableDict",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableRestrRule_StdTableColumnDictId",
                table: "MainStdTableRestrRule",
                column: "StdTableColumnDictId");

            migrationBuilder.CreateIndex(
                name: "IX_MainStdTableRestrRule_StdTableDictId",
                table: "MainStdTableRestrRule",
                column: "StdTableDictId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MainStdTableRestrRule");
        }
    }
}
